package com.paic.icore.test.demo.service.impl;

import com.paic.icore.test.demo.dao.UserMapper;
import com.paic.icore.test.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.paic.icore.test.demo.entity.Country;
import com.paic.icore.test.demo.service.CountryService;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 描述:
 *
 * @author HUXINGJIE666
 * @date 2017年12月19日下午3:19:04
 */
@Service
public class CountryServiceImpl implements CountryService {
    @Autowired
    private UserMapper userMapper;

    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    @Override
    public void updateUserC(User user) {
        user.setAddress("CountryServiceImpl");
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
    @Override
    public User selectUser(Long id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Transactional()
    @Override
    public void deleteUser(Long id) {

        userMapper.deleteByPrimaryKey(id);
        throw  new  RuntimeException();
    }
}
